Skip to content

tty: add raw-vt and io raw modes - #64140

Merged
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
samuel-williams-shopify:tty-raw-vt-io-mode
Aug 23, 2026
Merged

tty: add raw-vt and io raw modes#64140
nodejs-github-bot merged 5 commits into
nodejs:mainfrom
samuel-williams-shopify:tty-raw-vt-io-mode

Conversation

@samuel-williams-shopify

@samuel-williams-shopify samuel-williams-shopify commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Adds string raw-mode selection to tty.ReadStream#setRawMode():

  • setRawMode(true) keeps the existing behavior.
  • setRawMode('raw') explicitly selects the existing Node raw mode, backed by libuv UV_TTY_MODE_RAW_VT.
  • setRawMode('io') selects libuv UV_TTY_MODE_IO for binary-safe I/O mode on Unix.
  • readStream.rawMode exposes the exact current mode while readStream.isRaw remains boolean for compatibility.
  • Unknown string modes are rejected.

This is intended to address the output-processing distinction discussed in #63059 and follows libuv's existing UV_TTY_MODE_IO semantics. It preserves the current setRawMode(true) behavior instead of changing it.

Related libuv hardening PR: libuv/libuv#5174

Refs: #63059
Refs: libuv/libuv#32

Local verification:

  • git diff --check passes.
  • A full local build could not complete because macOS killed Cargo build-script-build executables as untrusted on this machine; relying on CI for the native build and pseudo-tty test run.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. tty Issues and PRs related to the tty subsystem. labels Jun 26, 2026
@samuel-williams-shopify
samuel-williams-shopify force-pushed the tty-raw-vt-io-mode branch 4 times, most recently from f8d0128 to 5831aec Compare June 26, 2026 04:22
Comment thread doc/api/tty.md Outdated
raw device. If `false`, configures the `tty.ReadStream` to operate in its
default mode. The `readStream.isRaw` property will be set to the resulting
mode.
* `mode` {boolean|string} If `true` or `'raw-vt'`, configures the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not use 'raw-vt' as a name and instead just use 'raw'. UV_TTY_MODE_RAW_VT is what UV_TTY_MODE_RAW should probably have been all along – the only reason they aren't merged (yet) into a single constant is backwards compatibility expectations in libuv.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, updated.

Comment thread lib/tty.js
@samuel-williams-shopify

Copy link
Copy Markdown
Contributor Author

Related libuv hardening PR: libuv/libuv#5174

That PR makes Unix uv_tty_set_mode() return UV_EINVAL for unrecognized uv_tty_mode_t values, matching the existing Windows behavior.

@addaleax addaleax added author ready PRs that have at least one approval, no outstanding review comments, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jun 30, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 30, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@samuel-williams-shopify

Copy link
Copy Markdown
Contributor Author

I can't see the CI failures, it says access denied.

@addaleax

addaleax commented Jul 2, 2026

Copy link
Copy Markdown
Member

@samuel-williams-shopify The failures seem exclusively related to alpine:

  ...
 length differs.
expect=4
actual=7
patterns:
pattern = ^raw=true$
pattern = ^normal=false$
pattern = ^raw\-string=true$
pattern = ^io=false$
outlines:
outline = stty: standard input: Not a tty
outline = raw=true
outline = normal=false
outline = stty: standard input: Not a tty
outline = raw-string=true
outline = stty: standard input: Not a tty
outline = io=false
not ok 5141 pseudo-tty/test-set-raw-mode-modes
  ---
  duration_ms: 287.86900
  severity: fail
  stack: |-
    stty: standard input: Not a tty
    raw=true
    normal=false
    stty: standard input: Not a tty
    raw-string=true
    stty: standard input: Not a tty
    io=false
  ...

Not sure what's different on the Alpine runners, I guess if there's no obvious reason for this it might be fine to silence stderr for stty instead of specifying inherit there

@samuel-williams-shopify

Copy link
Copy Markdown
Contributor Author

Pushed a test-only update in 7af5c59 to capture stty stderr in test-set-raw-mode-modes instead of inheriting it. This should prevent Alpine's stty: standard input: Not a tty message from polluting the pseudo-tty expected-output comparison while still surfacing stderr if stty exits non-zero.

I can't trigger or view the Jenkins run from here, and the new GitHub checks appear to be waiting for maintainer approval. Could a maintainer approve/rerun CI when convenient?

@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 26, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 26, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikr trivikr removed the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Aug 20, 2026
@trivikr

trivikr commented Aug 20, 2026

Copy link
Copy Markdown
Member

This PR needs to a rebase to resolve conflicts in doc/api/tty.md

Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
@samuel-williams-shopify

Copy link
Copy Markdown
Contributor Author

@trivikr done.

@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 22, 2026
@trivikr trivikr added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Aug 22, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 22, 2026
@nodejs-github-bot

This comment was marked as resolved.

@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.05882% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.11%. Comparing base (9472421) to head (f94af6e).
⚠️ Report is 64 commits behind head on main.

Files with missing lines Patch % Lines
src/tty_wrap.cc 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64140      +/-   ##
==========================================
- Coverage   90.12%   90.11%   -0.02%     
==========================================
  Files         752      752              
  Lines      252312   252338      +26     
  Branches    47432    47444      +12     
==========================================
- Hits       227404   227398       -6     
- Misses      16217    16265      +48     
+ Partials     8691     8675      -16     
Files with missing lines Coverage Δ
lib/tty.js 96.33% <100.00%> (+0.50%) ⬆️
src/tty_wrap.cc 82.27% <83.33%> (-0.62%) ⬇️

... and 32 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikr trivikr added the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 23, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Aug 23, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Commit Queue failed

This pull request has multiple commits, but no landing policy was selected.

Add commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. to land it as one commit, or commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. to land the commits separately.

The pull request was removed from the Commit Queue and labeled commit-queue-failed An error occurred while landing this pull request using GitHub Actions. . After resolving the failure, remove that label and add commit-queue Add this label to land a pull request using GitHub Actions. to retry.

Full Commit Queue output
- Loading data for nodejs/node/pull/64140
✔  Done loading data for nodejs/node/pull/64140
----------------------------------- PR info ------------------------------------
Title      tty: add raw-vt and io raw modes (#64140)
Author     Samuel Williams <samuel.williams@shopify.com> (@samuel-williams-shopify, first-time contributor)
Branch     samuel-williams-shopify:tty-raw-vt-io-mode -> nodejs:main
Labels     c++, tty, author ready, needs-ci, commit-queue
Commits    5
 - tty: add raw-vt and io raw modes
 - doc: update tty raw mode PR-URL
 - tty: use raw as public raw mode name
 - tty: reject unknown raw mode strings
 - test: silence stty stderr in raw mode test
Committers 1
 - Samuel Williams <samuel.williams@shopify.com>
PR-URL: https://github.com/nodejs/node/pull/64140
Refs: https://github.com/nodejs/node/issues/63059
Refs: https://github.com/libuv/libuv/issues/32
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/64140
Refs: https://github.com/nodejs/node/issues/63059
Refs: https://github.com/libuv/libuv/issues/32
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Fri, 26 Jun 2026 04:05:37 GMT
   ✔  Approvals: 3
   ✔  - Anna Henningsen (@addaleax): https://github.com/nodejs/node/pull/64140#pullrequestreview-4599153146
   ✔  - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/64140#pullrequestreview-4629888278
   ✔  - Trivikram Kamat (@trivikr): https://github.com/nodejs/node/pull/64140#pullrequestreview-5000667735
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2026-08-23T05:18:11Z: https://ci.nodejs.org/job/node-test-pull-request/76273/
- Querying data for job/node-test-pull-request/76273/
✔  Build data downloaded
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
   7072d76a5c..a89fc17cce  main       -> origin/main
✔  origin/main is now up-to-date
main is out of sync with origin/main. Mismatched commits:
 - fe654d1a54 stream: reuse unexposed managed read buffers
 - a89fc17cce stream: reuse unexposed managed read buffers
--------------------------------------------------------------------------------
HEAD is now at a89fc17cce stream: reuse unexposed managed read buffers
   ✔  Reset to origin/main
- Downloading patch for 64140
From https://github.com/nodejs/node
 * branch                  refs/pull/64140/merge -> FETCH_HEAD
✔  Fetched commits as eae0ca39be9c..f94af6ec6e76
--------------------------------------------------------------------------------
[main 6ebb60c5ec] tty: add raw-vt and io raw modes
 Author: Samuel Williams <samuel.williams@shopify.com>
 Date: Fri Jun 26 16:05:18 2026 +1200
 5 files changed, 92 insertions(+), 12 deletions(-)
 create mode 100644 test/pseudo-tty/test-set-raw-mode-modes.js
 create mode 100644 test/pseudo-tty/test-set-raw-mode-modes.out
[main 18f60e82d3] doc: update tty raw mode PR-URL
 Author: Samuel Williams <samuel.williams@shopify.com>
 Date: Tue Jun 30 11:38:26 2026 +1200
 1 file changed, 1 insertion(+), 1 deletion(-)
[main cd13331424] tty: use raw as public raw mode name
 Author: Samuel Williams <samuel.williams@shopify.com>
 Date: Tue Jun 30 11:38:39 2026 +1200
 4 files changed, 11 insertions(+), 11 deletions(-)
[main d68dc705ab] tty: reject unknown raw mode strings
 Author: Samuel Williams <samuel.williams@shopify.com>
 Date: Tue Jun 30 11:39:07 2026 +1200
 2 files changed, 17 insertions(+), 1 deletion(-)
[main 347777f3e0] test: silence stty stderr in raw mode test
 Author: Samuel Williams <samuel.williams@shopify.com>
 Date: Fri Jul 3 21:24:20 2026 +1200
 1 file changed, 3 insertions(+), 3 deletions(-)
   ✔  Patches applied
There are 5 commits in the PR. Attempting autorebase.
(node:1323) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
tty: add raw-vt and io raw modes

Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
PR-URL: https://github.com/nodejs/node/pull/64140
Refs: https://github.com/nodejs/node/issues/63059
Refs: https://github.com/libuv/libuv/issues/32
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
[detached HEAD 9062b86765] tty: add raw-vt and io raw modes
 Author: Samuel Williams <samuel.williams@shopify.com>
 Date: Fri Jun 26 16:05:18 2026 +1200
 5 files changed, 92 insertions(+), 12 deletions(-)
 create mode 100644 test/pseudo-tty/test-set-raw-mode-modes.js
 create mode 100644 test/pseudo-tty/test-set-raw-mode-modes.out
Rebasing (3/10)
Rebasing (4/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
doc: update tty raw mode PR-URL

Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
PR-URL: https://github.com/nodejs/node/pull/64140
Refs: https://github.com/nodejs/node/issues/63059
Refs: https://github.com/libuv/libuv/issues/32
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
[detached HEAD c899fb3810] doc: update tty raw mode PR-URL
 Author: Samuel Williams <samuel.williams@shopify.com>
 Date: Tue Jun 30 11:38:26 2026 +1200
 1 file changed, 1 insertion(+), 1 deletion(-)
Rebasing (5/10)
Rebasing (6/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
tty: use raw as public raw mode name

Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
PR-URL: https://github.com/nodejs/node/pull/64140
Refs: https://github.com/nodejs/node/issues/63059
Refs: https://github.com/libuv/libuv/issues/32
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
[detached HEAD b0d51a9df8] tty: use raw as public raw mode name
 Author: Samuel Williams <samuel.williams@shopify.com>
 Date: Tue Jun 30 11:38:39 2026 +1200
 4 files changed, 11 insertions(+), 11 deletions(-)
Rebasing (7/10)
Rebasing (8/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
tty: reject unknown raw mode strings

Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
PR-URL: https://github.com/nodejs/node/pull/64140
Refs: https://github.com/nodejs/node/issues/63059
Refs: https://github.com/libuv/libuv/issues/32
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
[detached HEAD 994d15e30a] tty: reject unknown raw mode strings
 Author: Samuel Williams <samuel.williams@shopify.com>
 Date: Tue Jun 30 11:39:07 2026 +1200
 2 files changed, 17 insertions(+), 1 deletion(-)
Rebasing (9/10)
Rebasing (10/10)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
test: silence stty stderr in raw mode test

Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
PR-URL: https://github.com/nodejs/node/pull/64140
Refs: https://github.com/nodejs/node/issues/63059
Refs: https://github.com/libuv/libuv/issues/32
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
--------------------------------------------------------------------------------
[detached HEAD 9894a86a37] test: silence stty stderr in raw mode test
 Author: Samuel Williams <samuel.williams@shopify.com>
 Date: Fri Jul 3 21:24:20 2026 +1200
 1 file changed, 3 insertions(+), 3 deletions(-)
Successfully rebased and updated refs/heads/main.
--------------------------------------------------------------------------------
   ℹ  Add `commit-queue-squash` label to land the PR as one commit, or `commit-queue-rebase` to land as separate commits.

View workflow run

@trivikr trivikr added commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Aug 23, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 0b89f8f into nodejs:main Aug 23, 2026
88 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 0b89f8f

@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. tty Issues and PRs related to the tty subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants